package com.thread.lesson.lambda;

/**
 * @Author: Mr.Xi
 * @Description:
 * @Date: Create in 17:46 2021/7/1
 * @Modified By:
 */

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

/**
 * 推到Lambda表达式
 */
public class TestLambda1 {
    //3.静态内部类
    static class Like2 implements iLike{
        @Override
        public void lambda() {
            System.out.println("i like lambda2");
        }
    }

    public static void main(String[] args) {
        //原始方式
        iLike like = new Like();
        like.lambda();

        //静态内部类方式：
        like = new Like2();
        like.lambda();

        //4.局部内部类方式：
        class Like3 implements iLike{
            @Override
            public void lambda() {
                System.out.println("i like lambda3");
            }
        }
        like = new Like3();
        like.lambda();

        //5.匿名内部类方式：没有类的名称，必须借助接口或者父类
        like = new iLike() {
            @Override
            public void lambda() {
                System.out.println("i like lambda4");
            }
        };
        like.lambda();

        //6.用Lambda简化
        like = () -> {
            System.out.println("i like lambda5");
        };
        like.lambda();


    }

}

//1.定义一个函数式接口
interface iLike{
    void lambda();
}
//2.实现类
class Like implements iLike{
    @Override
    public void lambda() {
        System.out.println("i like lambda1");
    }
}